refactor: split s7/ into standalone s7commplus/ package#774
Conversation
|
@ale-rinaldi @Erik1000 @EliTheCoder @xBiggs — this PR splits the unified
There's also a new Would appreciate your review on whether the new package structure makes sense and nothing got lost in the move. The PR description has the full file mapping. |
|
Guess it makes sense if the protocols differ so much and its definitely better than catching exceptions everywhere. |
|
Overall I'm in favour of the direction — a few thoughts, since you asked. The split itself: 👍 Explicit The HarpoS7
One inconsistency worth a look — the Offer: the session-auth path is exactly what's still failing for us on real hardware (the legitimation challenge fetch in #718). We have an S7-1200 (1211C, FW4.6) and an S7-1500 (1507S, FW21.9) on hand — happy to run this branch against both and report whether legitimation/integrity actually completes end-to-end, which the emulated-server tests can't cover. Just say the word. |
|
ah wait, i didn't realise the session auth stuff was also in this PR. going to take that out, it is not ready yet and quite a mess. |
The unified s7/ package auto-negotiated between S7CommPlus and legacy S7, but the silent fallback created confusing errors (#760, #710). Split the S7CommPlus implementation into s7commplus/, delete the unified wrappers, and force users to explicitly choose snap7.Client (legacy S7-300/400) or s7commplus.Client (S7CommPlus S7-1200/1500). The s7/ package is retained as a snap7 alias for backward compat. File moves: - s7/_s7commplus_client.py → s7commplus/client.py - s7/_s7commplus_async_client.py → s7commplus/async_client.py - s7/_s7commplus_server.py → s7commplus/server.py - s7/{connection,protocol,codec,vlq,legitimation,typeinfo}.py → s7commplus/ Deleted unified wrappers: - s7/client.py, s7/async_client.py, s7/server.py, s7/_protocol.py - s7/partner.py, s7/util.py Updated: all tests, examples, docs, pyproject.toml, tox.ini, Makefile. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
37e21f0 to
ed71eb1
Compare
Update docs, README, CLAUDE.md, and examples to use `from s7 import` as the recommended import for the legacy S7 protocol. The `snap7` name continues to work for backwards compatibility but is no longer the primary recommendation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Thanks both for the feedback. @Erik1000 — agreed, explicit protocol choice is much better than catching surprises. @ale-rinaldi — good review, addressing each point: session_auth: Removed from this PR entirely — it was accidentally included via the base branch. It'll come as a separate PR with proper license attribution, CI-wired transpilation verification, and documentation on where Family-0 plugs in. Your notes on all of those are spot-on and will be addressed there. The
No cross-wiring between Hardware testing offer: Would love that — let's pick it up on the session_auth PR once it's ready. Having real S7-1200 FW4.6 + S7-1500 FW21.9 coverage would be invaluable for the legitimation path. |
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
This looks like a great step towards a more robust and secure S7CommPlus setup! 🚀😸 Maintainer? Turn off weaves from non-maintainers → |
Rebased onto the s7commplus/ package split (#774). All session_auth code now lives under s7commplus/session_auth/ instead of s7/session_auth/. Adds the full session_auth package for V1-initial S7-1200 PLCs that require a SessionKey handshake before data operations: - s7commplus/session_auth/: Public-key-based session authentication (Family 0 key derivation, fingerprint matching, SecurityKeyEncryptedKey blob generation, legitimation challenge solver, HMAC key derivation) - V3 HMAC framing for post-auth data operations - TIA-style CreateObject attributes (required by V1-initial firmware) - PAOM string stripping in ServerSessionVersion echo - Post-auth legitimation flow (challenge read + solved blob write) - Connection.connect(password=) parameter for auth flow Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
Implements #769 — splits the S7CommPlus protocol implementation out of the unified
s7/package into a standalones7commplus/package and deletes the auto-negotiating unified wrappers.s7commplus/package created with the S7CommPlus implementation renamed from internal modules to clean public namess7/package repurposed as an alias forsnap7—from s7 import Clientis now the recommended way to use the legacy S7 protocol (replacingfrom snap7 import Client, which still works)s7.Client(legacy S7-300/400) ors7commplus.Client(S7CommPlus S7-1200/1500)File moves
s7/_s7commplus_client.pys7commplus/client.pys7/_s7commplus_async_client.pys7commplus/async_client.pys7/_s7commplus_server.pys7commplus/server.pys7/{connection,protocol,codec,vlq,legitimation,typeinfo}.pys7commplus/Deleted (unified wrappers)
s7/client.py— auto-negotiating Client withProtocol.AUTOs7/async_client.py,s7/server.py— unified async client and dual-protocol servers7/_protocol.py—Protocolenum (AUTO/LEGACY/S7COMMPLUS)s7/partner.py,s7/util.py— pure re-exports of snap7 modulestests/test_s7_unified.py— tested the deleted unified wrappersUpdated
from s7.→from s7commplus.s7oversnap7for legacy protocolBreaking changes (vs unreleased 4.0-dev only — 3.x is unaffected)
from s7 import Clientnow returns the legacysnap7.Clientinstead of the auto-negotiating S7CommPlus client — usefrom s7commplus import Clientfor S7CommPlusProtocolenum removed — no moreProtocol.AUTO/Protocol.S7COMMPLUSs7.Serverremoved — uses7commplus.Serverors7.server.ServerdirectlyTest plan
🤖 Generated with Claude Code